export default function swap(
	i: number | string,
	j: number | string,
	arr: Array<any>
): boolean | never {
	// 类型判断
	if (!Array.isArray(arr)) {
		throw new Error("The third argument must be an array");
	}
	i = parseInt(i as string);
	j = parseInt(j as string);
	const length = arr.length;
	// 越界判断
	if (i < 0 || i >= length || j < 0 || j >= length) {
		throw new Error(`Can't read a data overstep the boundary`);
	}

	let temp = arr[i];
	arr[i] = arr[j];
	arr[j] = temp;

	return true;
}
